<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/10/20/0020
 * Time: 16:32
 */

namespace App\Transformers;


use App\Models\Good;
use App\Models\GoodCategory;
use League\Fractal\TransformerAbstract;

class GoodslistTransformer extends TransformerAbstract
{
    protected $availableIncludes = ['category',''];

    public function transform(Good $good){
        return [
            'id' => $good->id,
            'goods_name' => $good->goods_name,
            'good_category_id' => $good->good_category_id,
            'store_count' => $good->store_count,
            'market_price' => $good->market_price,
            'shop_price' => $good->shop_price,
            'admin_id' => $good->admin_id,
        ];
    }

    public function includeCategory(Good $good){

        return $this->item($good->category,new CategoryTransformer());
    }

    public function includeJinpai(){

    }
}